use std::collections::HashMap;
use tokio::fs;
use crate::config::json_file;
use crate::models::FileEntry::FileEntry;

pub async fn load_file_database(add:&str)->HashMap<String,FileEntry>{
    match fs::read_to_string(add).await{
        Ok(content)=>{
            if content.trim().is_empty(){
                println!("第9行file.json is empty");
                HashMap::new()
            }else{
                println!("第14行读取成功{}",content);
            let value =    serde_json::from_str(&content).expect("Failed to parse file.json");
                println!("第16行读取成功{:?}",value);
                value
            }
        },
        Err(_)=>{
            println!("第17行读取失败");
            HashMap::new()
        }
    }
}
pub async fn load_file_Md5(add:&str)->HashMap<u64,String>{
    match fs::read_to_string(add).await{
        Ok(content)=>{
            if content.trim().is_empty(){
                println!("第9行file.json is empty");
                HashMap::new()
            }else{
                println!("第32行读取成功{}",content);
                let value =serde_json::from_str(&content).expect("Failed to parse file.json");
                println!("第34行读取成功{:?}",value);
                value
            }
        },
        Err(_)=>{
            println!("第17行读取失败");
            HashMap::new()
        }
    }
}